#!/usr/bin/env bash
set -euo pipefail

MIRRORS=(
	"https://docker.1ms.run",
	"https://docker.1panel.live",
	"https://docker.xuanyuan.me",
	"https://hub.rat.dev",
	"https://dhub.kubesre.xyz",
	"https://docker.m.daocloud.io",
	"https://hub.amingg.com",
	"https://hub1.nat.tf",
	"https://docker.amingg.com",
	"https://docker.sunzishaokao.com",
	"https://image.cloudlayer.icu",
	"https://docker-0.unsee.tech",
	"https://docker.hlmirror.com",
	"https://docker.kejilion.pro",
	"https://docker.tbedu.top",
	"https://ccr.ccs.tencentyun.com"
	"https://hub.xdark.top"
	"https://dhub.kubesre.xyz"
	"https://docker.kejilion.pro"
	"https://docker.xuanyuan.me"
	"https://docker.hlmirror.com"
	"https://run-docker.cn"
	"https://docker.sunzishaokao.com"
	"https://image.cloudlayer.icu"
	"https://docker.tbedu.top"
	"https://hub.crdz.gq"
	"https://docker.melikeme.cn"
)

printf "%-34s  %-10s  %-s\n" "MIRROR" "V2(ms)" "NOTES"
for m in "${MIRRORS[@]}"; do
	t=$(curl -o /dev/null -s -w "%{time_total}" "${m}/v2/" || echo "fail")
	note=""
	if [[ "$t" == "fail" ]]; then
		note="connect error"
	else
		t=$(awk -v n="$t" 'BEGIN{printf "%.0f", n*1000}')
	fi
	printf "%-34s  %-10s  %-s\n" "$m" "$t" "$note"
done
